package com.lst.demo.recycleview;

import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.widget.Button;

import com.lst.demo.R;
import com.lst.demo.recycleview.adapter.ListGvRecycleAdapter;
import com.lst.demo.recycleview.adapter.ListLvRecycleAdapter;
import com.lst.demo.recycleview.bean.PersonBean;

import java.util.ArrayList;
import java.util.List;

/**
 * create by Lst
 * on 2020/4/8
 */
public class RecycleSwitchActivity extends AppCompatActivity {

    private Button btnSwitch;
    private RecyclerView mRecycle;

    private ListGvRecycleAdapter gvAdapter;
    private ListLvRecycleAdapter lvAdapter;

    private List<PersonBean> listData;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_recycleswitch);

        btnSwitch = findViewById(R.id.btn_switch);
        mRecycle = findViewById(R.id.my_recycle);

        listData = new ArrayList<>();

    }

    public void swicthRecycle() {
        String s = btnSwitch.getText().toString();
    }


    /**
     * 列表类型
     */
    private void setRecycleLv() {

        lvAdapter = new ListLvRecycleAdapter(this, listData);
        mRecycle.setLayoutManager(new LinearLayoutManager(this));
        mRecycle.setAdapter(lvAdapter);

    }


    /**
     * 网格类型
     */
    private void setRecycleGv() {
        gvAdapter = new ListGvRecycleAdapter(this, listData);
        mRecycle.setLayoutManager(new GridLayoutManager(this, 4));
        mRecycle.setAdapter(gvAdapter);
    }


}
